package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.postListPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * ClassName:postListMapp
 * Description:
 *
 * @Author 赵永峰
 * @Create 2025/10/15 20:18
 * @Version 1.0
 */
@Mapper
public interface postListMapp {
    //插入一行数据
    @DS("newMscLowCodeFormal")
    @Insert("INSERT INTO ddm_post_list (" +
            "id, create_time, update_time, creator, process_status, sys_update_user, sys_audit_user, " +
            "sys_audit_time, sys_deleted, post_name, content, requirement, cycle, completion_date, " +
            "category, working_time, everyday, instruction, source,orderId" +
            ") VALUES (" +
            "#{id}, #{create_time}, #{update_time}, #{creator}, #{process_status}, #{sys_update_user}, #{sys_audit_user}, " +
            "#{sys_audit_time}, #{sys_deleted}, #{post_name}, #{content}, #{requirement}, #{cycle}, #{completion_date}, " +
            "#{category}, #{working_time}, #{everyday}, #{instruction}, #{source},#{orderId}" +
            ")")
    void insertOne(postListPojo pojo);
    //对岗位List根据某一个字段查询等于某一个值的所有值
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_post_list where ${fieldName}=#{fieldVal} and sys_deleted=0 ORDER BY orderId ASC")
    List<postListPojo> inquiryOneFieldValue(String fieldName, String fieldVal);
    //辅助函数：岗位List表中，修改一行数据
    @DS("newMscLowCodeFormal")
    @Update("UPDATE ddm_post_list SET " +
            "create_time = #{create_time}, " +
            "update_time = #{update_time}, " +
            "creator = #{creator}, " +
            "process_status = #{process_status}, " +
            "sys_update_user = #{sys_update_user}, " +
            "sys_audit_user = #{sys_audit_user}, " +
            "sys_audit_time = #{sys_audit_time}, " +
            "sys_deleted = #{sys_deleted}, " +
            "post_name = #{post_name}, " +
            "content = #{content}, " +
            "requirement = #{requirement}, " +
            "cycle = #{cycle}, " +
            "completion_date = #{completion_date}, " +
            "category = #{category}, " +
            "working_time = #{working_time}, " +
            "everyday = #{everyday}, " +
            "instruction = #{instruction}, " +
            "source = #{source}," +
            "orderId= #{orderId} " +
            "WHERE id = #{id}")
    void editOneRow(postListPojo pojo);
}
